// Copyright (c) 2012 Ecma International.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 12.14-13
description: catch introduces scope - updates are based on scope
flags: [noStrict]
---*/

function Test() {
            var res1 = false;
            var res2 = false;
            var res3 = false;

    (function() {
            var x_12_14_13 = 'local';

                function foo() {
                    this.x_12_14_13 = 'instance';
                }

                try {
                    throw foo;
                }
                catch (e) {
                    res1 = (x_12_14_13 === 'local');
                    e();
                    res2 = (x_12_14_13 === 'local');
                }
                res3 = (x_12_14_13 === 'local');
    })();

    assert(res1, 'res1 !== true');
    assert(res2, 'res2 !== true');
    assert(res3, 'res3 !== true');
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
